<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@include file="view/link.jsp" %>
<html>
<head>
    <title>首页</title>

    <style type="text/css">
        div {
            border: 1px solid blue;
        }

        #div_0 {
            width: 1300px;
            height: 700px;
            margin: 50px auto;
            padding: 10px;
        }

        #div_left {
            width: 385px;
            height: 685px;
            float: left;
        }

        #div_right {
            width: 885px;
            height: 685px;
            float: right;
        }

        #div_left div {
            width: 380px;
            height: 225px;
        }

        #div_left li {
            list-style-type: none;
            height: 35px;
        }

        h3 {
            color: red;
        }

        #div_logo {
            width: 500px;
            height: 130px;
            float: left;
            background-image: url("<c:url value='/img/log.png'/>");
            background-repeat: no-repeat;
            background-position: center;
        }

        #div_logout {
            width: 200px;
            height: 130px;
            float: right;
            text-align: right;
        }

        #div_top {
            width: 870px;
            height: 140px;
            margin: 2px auto;
        }


    </style>
</head>
<script type="text/javascript">
    $(function () {
        //文档加载完毕  给span_time设置内容
        window.setInterval(setSpanTime, 1000);

        function setSpanTime() {
            $("#span_time").html(new Date().toLocaleString().bold().fontcolor("red"));
        }
    })
</script>
<body>
<h3>在线人数${sessionScope.applicationSet.size()}</h3>
<div id="div_0">
    <div id="div_left">
        <div id="div_user">
            <!-- 如果session域中有user  显示登录者的信息  如果没有显示登录表单 -->
            <jsp:include page="/user_login.jsp"/>
        </div>
        <div id="div_star">
            <h3>明星用户</h3>
            <ul>
                <c:forEach items="${startUserList}" var="user">
                    <li><a href="${pageContext.request.contextPath}/user/show?uid=${user.uid}">${user.uname}</a></li>
                </c:forEach>
            </ul>
        </div>
        <div id="div_hot">
            <h3>热点话题</h3>
            <ul>
                <c:forEach items="${topicList}" var="title">
                    <%--点击话题跳转话题详情--%>
                    <li><a href="/title/showMessage?tid=${title.tid}">${title.tname}</a></li>
                </c:forEach>
            </ul>
        </div>
    </div>
    <div id="div_right">
        <div id="div_top">
            <div id="div_logo"></div>
            <div id="div_logout">
                <br/>
                <span id="span_time"></span><br/>
                <br/>
                <%--如果用户登录了就让他可以点击，如果没有就不行--%>
                <c:choose>
                    <c:when test="${empty sessionScope.loginUser}">
                        资料修改<br/>
                    </c:when>
                    <c:otherwise>
                        <a href="<c:url value='/index.jsp?pageName=user_update.jsp'/>">资料修改</a><br/>
                    </c:otherwise>
                </c:choose>
                <br/>
                <c:choose>
                    <c:when test="${empty sessionScope.loginUser}">
                        会员登出<br/>
                    </c:when>
                    <c:otherwise>
                        <a href="<c:url value='/user/logout'/>">会员登出</a><br/>
                    </c:otherwise>
                </c:choose>
            </div>
        </div>
        <div id="div_main">
            <%--如果--%>
            <c:choose>
                <c:when test="${not empty param.pageName}">
                    <jsp:include page="${param.pageName}"/>
                </c:when>
                <c:otherwise>
                    <jsp:include page="/title_list.jsp"/>
                </c:otherwise>
            </c:choose>
        </div>
        <div>

            <input type="text" id="queryText" style="height: 20px">
            <input type="button" id="querySubmit" value="关键字查询" style="height: 20px">

            <c:if test="${not empty sessionScope.loginUser}">
                &nbsp;&nbsp;&nbsp;&nbsp; <a
                    href="${pageContext.request.contextPath}/index.jsp?pageName=view/title_add.jsp">添加话题
            </a>
            </c:if>
        </div>
    </div>
</div>
</body>
<script>
    //分页查询
    $("#querySubmit").click(function () {
        let queryText = $("#queryText").val();
        $.ajax({
            //url: "/title/query",
            url: "${pageContext.request.contextPath}/title/paging",
            data: {"queryText": queryText},
            type: 'post',
            success: function () {
                //成功重新加载 容器
                $("#div_right").load("${pageContext.request.contextPath}/ #div_right");
            }
        })
    })

    /*单页面加载完成发送请求 */
    //如果域中没有 init就执行init进行初始话
    // $(function () {
    <c:if test="${empty init}">
    $.ajax({
        url: '/init/message',
        type: "post",
        success: function () {
            //成功重新加载 容器
            $("#div_0").load("${pageContext.request.contextPath}/index.jsp #div_0");
        },
    })
    </c:if>

    // })
</script>
</html>

<%--<link rel="stylesheet" href="${pageContext.request.contextPath}/css/live2d.css"/>
<div id="landlord" style="left:5px;bottom:0px;">
    <div class="message" style="opacity:0"></div>
    <canvas id="live2d" width="500" height="560" class="live2d"></canvas>
    <div class="live_talk_input_body">
        <div class="live_talk_input_name_body">
            <input name="name" type="text" class="live_talk_name white_input" id="AIuserName" autocomplete="off"
                   placeholder="你的名字"/>
        </div>
        <div class="live_talk_input_text_body">
            <input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off"
                   placeholder="要和我聊什么呀？"/>
            <button type="button" class="live_talk_send_btn" id="talk_send">发送</button>
        </div>
    </div>
    <input name="live_talk" id="live_talk" value="1" type="hidden"/>
    <div class="live_ico_box">
        <div class="live_ico_item type_info" id="showInfoBtn"></div>
        <div class="live_ico_item type_talk" id="showTalkBtn"></div>
        <div class="live_ico_item type_music" id="musicButton"></div>
        <div class="live_ico_item type_youdu" id="youduButton"></div>
        <div class="live_ico_item type_quit" id="hideButton"></div>
        <input name="live_statu_val" id="live_statu_val" value="0" type="hidden"/>
        <audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
        <input name="live2dBGM" value="音乐地址" type="hidden">
        <input id="duType" value="douqilai,l2d_caihong" type="hidden">
    </div>
</div>
<div id="open_live2d">召唤蕾姆</div>

<script>
    var message_Path = '/live2d/';//资源目录，如果目录不对请更改
    var talkAPI = "123";//如果有类似图灵机器人的聊天接口请填写接口路径（注意这里填写的是接口，没有可空着，页面上就不会显示对话按钮）
</script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/live2d.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/message.js"></script>--%>
